package com.sam.controller;

import com.sam.service.IDeepSeekService;
import jakarta.annotation.Resource;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

/**
 * AI
 *
 * @author <a href="mailto:807837863.qq.com">sam</a>
 * @since 2025-05-07 16:04
 */
@RestController
@RequestMapping("/ai/deepSeek")
public class DeepSeekController {

    @Resource
    private IDeepSeekService deepSeekService;

    /**
     * 直接回答
     * @param message
     * @return
     */
    @GetMapping(value = "/chat")
    public String chat(@RequestParam(value = "message") String message) {
        //return deepSeekService.chat(message);
        return deepSeekService.getResponse(message);
    }

    /**
     * 流式回答
     * @param message
     * @return
     */
    @GetMapping(value = "/chatFlux", produces = MediaType.APPLICATION_JSON_VALUE)
    public Flux<ChatResponse> chatFlux(@RequestParam(value = "message") String message) {
        return deepSeekService.chatFlux(message);
    }

}
